#ifndef MATERIAL_H_
#define MATERIAL_H_
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <stdio.h>
#include <time.h>

/* enumeration of the data format */
enum datfmt { MCNP, XML, FREE };

class Material
{
private:

    /* material id number */
    int _id;

    /* material name */
    char* _name;

    /* number of energy groups */
    int _groups;

    /* number of up-scattering group(s) */
    int _up;

    /* number of down-scattering group(s) */
    int _down;

    /* atomic density 10^24 cm^-3 */
    double _density;

    /* energy center and energy width */
    double* _energy_center;
    double* _energy_width;

    /* cross section arrays */
    double* _sigma_t;
    double* _sigma_f;
    double* _sigma_a;
    double* _sigma_s;

    /* fission nu arrays */
    double* _nu;

    /* nu*sigma_f array */
    double* _nu_sigma_f;

    /* chi array */
    double* _chi;

    /* input and output data format
    data format --> datfmt
    read from format fmtin
    write to format fmtout */
    // datfmt _fmtin;
    // datfmt _fmtout;

public:
    Material();
    virtual ~Material();

    // void setInFMT(datfmt in) { _fmtin = in; }
    // void setOutFMT(datfmt out) { _fmtout = out; }

    void setID(int id) { _id = id; }
    void setName(std::string name);
    void setID(std::vector<int> id);
    void setGroups(std::vector<int> groups);
    void setUp(std::vector<int> up);
    void setDown(std::vector<int> down);
    void setDensity(std::vector<double> density);
    void setSigma_t(std::vector<double> v);
    void setSigma_f(std::vector<double> v);
    void setSigma_a(std::vector<double> v);
    void setSigma_s(std::vector<double> v, std::string string);
    void setChi(std::vector<double> v);
    void setNu(std::vector<double> v);
    void setEnergyCenter(std::vector<double> v);
    void setEnergyWidth(std::vector<double> v);

    void initialize();
    void convert2Macro();

    void write(std::ofstream & fout, datfmt fmt);
    void print();
    void write(char* filename);
};

int max(int a, int b);

int min(int a, int b);

#endif /* MATERIAL */
